package com.modakai.med.hosp.controller;

import com.modakai.med.common.result.Result;
import com.modakai.med.hosp.service.HospitalService;
import com.modakai.med.model.hosp.Hospital;
import com.modakai.med.vo.HospitalQueryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@Tag(name = "医院管理接口")
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/hosp/hospital")

public class HospitalController {

    private final HospitalService hospitalService;

    @Operation(summary = "分页查询")
    @Parameters(value = {
            @Parameter(name = "page", description = "当前页码", required = true),
            @Parameter(name = "limit", description = "每页记录数", required = true),
            @Parameter(name = "queryVo", description = "查询条件", schema = @Schema(implementation = HospitalQueryVo.class))
    })
    @GetMapping("/{page}/{limit}")
    public Result<Page<Hospital>> index(@PathVariable("page") int page,
                                        @PathVariable("limit") int limit,
                                        HospitalQueryVo queryVo) {
        return Result.ok(hospitalService.selectPage(page, limit, queryVo));
    }

    @Operation(summary = "更新医院状态", parameters = {
            @Parameter(name = "id", description = "医院id", required = true),
            @Parameter(name = "status", description = "状态", required = true)
    })
    @PutMapping("updateStatus/{id}/{status}")
    public Result<String> lock(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }
}
